package me.hl.nio;

import java.io.IOException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;

/**
 * Created by Planck on 2016/2/22.
 */
public class SelectionKeyDemo {
    public SelectionKey getSelectionKey(SelectableChannel channel) {
        try {
            Selector selector = Selector.open();
            SelectionKey key = channel.register(selector, SelectionKey.OP_READ);
            return key;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }


}
